/**
 * 注释: 获取文件名，不带后缀
 *
 * */
export const getFileName = (path: string) => {
  return path.replace(/(.*\/)*([^.]+).*/gi, "$2");
};

export function isImage(fileName: string) {
  const suffix = `(bmp|jpg|png|tif|gif|pcx|tga|exif|fpx|svg|psd|cdr|pcd|dxf|ufo|eps|ai|raw|WMF|webp|jpeg)`;
  const regular = new RegExp(`.*\\.${suffix}`);
  return regular.test(fileName);
}

export function isMp4(fileName: string) {
  const suffix = `(avi|wmv|mpeg|mp4|m4v|mov|asf|flv|f4v|rmvb|rm|3gp|vob)`;
  const regular = new RegExp(`.*\\.${suffix}`);
  return regular.test(fileName);
}

export function camelToUnderline(str: string) {
  return str.replace(/([A-Z])/g, "_$1").toLowerCase();
}
